//
//  GLImageResource.m
//  QAQ打飞机
//
//  Created by admin on 15/8/28.
//  Copyright (c) 2015年 gl. All rights reserved.
//

#import "GLImageResource.h"

@implementation GLImageResource
#pragma mark -重写init方法
-(instancetype)init
{
    self =[super init];
    if (self !=nil) {
       //去图片路径
        NSString *imageBundlePath =[[[NSBundle mainBundle]bundlePath]stringByAppendingPathComponent:@"imageView.bundle"];
        NSBundle *bundle = [NSBundle bundleWithPath:imageBundlePath];
        //加载背景图像
        self.backImage =[self loadImageWithBundle:bundle name:@"F}}J@Z3D6X`D74AU[1ITFQA"];
        //加载英雄的图像
        self.heroFlyImages = [self loadImagesWithBundle:bundle format:@"英雄图像%d" count:2];
        self.heroBlowupImages =[self loadImagesWithBundle:bundle format:@"second_enemy1_blowup_%d" count:4];
        //加载子弹图像
        
        self.normalBulletImage =[self loadImageWithBundle:bundle name:@"p-f01"];
        self.enhancedBulletImage =[self loadImageWithBundle:bundle name:@"d_刀光-6_爱给网_2gei_com"];
        //加载装备图像
        self.equipImage=[self loadImagesWithBundle:bundle format:@"飞%d" count:4];
        //加载敌机图像
        //小飞机
       
        self.smallEnemyFlyImage =[self loadImageWithBundle:bundle name:@"p01-1"];
       
        NSLog(@"%@",self.smallEnemyFlyImage);
        self.smallenemyBlowpImages =[self loadImagesWithBundle:bundle format:@"second_enemy1_blowup_%d" count:4];
        //中飞机
        self.midEnemyFlyImage =[self loadImageWithBundle:bundle name:@"a4-2"];
        self.midEnemyBlowupImages =[self loadImagesWithBundle:bundle format:@"a4-%d" count:5];
        self.midEnemyHitImage =[self loadImageWithBundle:bundle name:nil];
        //大飞机
        self.bigEnemyFlyImages =[self loadImageWithBundle:bundle name:@"select-plane1"];
        self.bigEnemyBlowupImages =[self loadImagesWithBundle:bundle format:@"second_enemy1_blowup_%d" count:4];
        self.bigEnemyHitImage =[self loadImageWithBundle:bundle name:@"enemy2_hit_1"];
        //暂停继续
        self.btnPauseImage =[self loadImageWithBundle:bundle name:@"soundon1_cover"];
        self.btnpauseImageHL =[self loadImageWithBundle:bundle name:@"BurstAircraftPauseHL"];
        self.btnStartImage =[self loadImageWithBundle:bundle name:@"soundon2_cover"];
        self.btnStartImageHL=[self loadImageWithBundle:bundle name:@"BurstAircraftStartHL"];
        //炸弹按钮
        self.btnBombButton =[self loadImageWithBundle:bundle name:@"missile_bt"];
        self.btnBomb=[self loadImageWithBundle:bundle name:@"stageClass1"];
        self.btnBombHL =[self loadImageWithBundle:bundle name:@"stageClass2"];
        //开始游戏
        self.BeginGameImage =[self loadImageWithBundle:bundle name:@"开始游戏"];
        self.BeginScoreImage =[self loadImageWithBundle:bundle name:@"排行榜"];
        //返回按钮
        self.Returnimage =[self loadImageWithBundle:bundle name:@"back_peek0"];
        self.ReturnimageHL =[self loadImageWithBundle:bundle name:@"back_peek1"];
        //排行榜视图背景图片
        self.scoreimage =[self loadImageWithBundle:bundle name:@"show_crystal"];
    }

    return self;

}
#pragma mark -私有方法
#pragma mark 通过bundle取指定图像
-(UIImage *)loadImageWithBundle:(NSBundle *)bundle name:(NSString *)imageName
{
    NSString *imagePath =[bundle pathForResource:imageName ofType:@"png"];

    return [UIImage imageWithContentsOfFile:imagePath];
}
#pragma mark 通过bundle 取某种格式的多个图像
-(NSArray *)loadImagesWithBundle:(NSBundle *)bundle format:(NSString *)format
 count:(NSInteger)count
{
    NSMutableArray *images = [NSMutableArray arrayWithCapacity:count];
    for (NSInteger i =1; i<=count; i++) {
        NSString *name = [NSString stringWithFormat:format,i];
        UIImage *temp =[self loadImageWithBundle:bundle name:name];
        [images addObject:temp];
        
    }
   
    return images;
}
@end
